package com.chhuang.myplayer.ui.activity

import android.annotation.SuppressLint
import android.view.View
import androidx.core.view.ViewCompat
import androidx.core.view.ViewPropertyAnimatorListener
import com.chhuang.myplayer.R
import com.chhuang.myplayer.base.BaseActivity
import org.jetbrains.anko.find
import org.jetbrains.anko.startActivity

@SuppressLint("CustomSplashScreen")
class SplashActivity: BaseActivity() {
    override fun getLayoutId(): Int {
        return R.layout.activity_splash
    }

    override fun initData() {
        super.initData()
        //动画缩放x轴方向与y轴方向，时间为2秒，监听动画结束后跳转到主界面
        ViewCompat.animate(find(R.id.splashImageView)).scaleX(1f).scaleY(1f)
            .setListener(object: ViewPropertyAnimatorListener{
                override fun onAnimationStart(view: View?) {}
                override fun onAnimationEnd(view: View?) {
                    //动画结束之后进入主界面
    //                    startActivity<MainActivity>()
    //                    finish()//主界面返回就不会显示到splash activity
                    startActivityAndFinish<MainActivity>()
                }

                override fun onAnimationCancel(view: View?) {}
            }).duration = 2000
    }
}